<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="dao.DaoFactory"%>
<%@page import="service.IProductDao"%>
<%@page import="bean.Product" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>显示产品信息</title>
   <script>
   	function fun(val){
   		var r=confirm("确认删除吗？");
   		if(r){
   			location.href="OperatorServlet?op=del&id="+val;
   		}
   	}
   </script>
   <style>
   a{
    		text-decoration: none;
    		
    	}
   </style>
   
  </head>
  
  <body>
	<div>
		<form action="OperatorServlet?op=select" method="post" class="search">
			<input style="border-radius: 0px; width: 328px;" name="searchText"
				type="text" placeholder="请输入名称或产地">
			<input name="查询商品"
				type="submit" value="查询商品">
		</form>

	</div>
	<center>
	<!-- 这是新的商品展示页，使用jstl表达式，遍历后台传递的值 -->
		<table border="1" style="border:2px solid RGB(73,161,225)">
		<tr>
    			<th width="100">编号</th>
    			<th width="100">名称</th>
    			<th width="100">产地</th>
    			<th width="100">价格</th>
				<th width="100">商品信息</th>
				<th width="100">适用对象</th>
    			<th colspan="2" width="200">操作</th>	
    		</tr>
			<c:forEach var="Product" items="${productList}">
				<tr align="center">

					<td>${Product.id}</td>
					<td>${Product.name}</td>
					<td>${Product.addr}</td>
					<td>${Product.price}</td>
					<td>${Product.shopmsg}</td>
					<td>${Product.object}</td>
					<td><a href="update.jsp?id=${Product.id}&op=update">更新</a></td>
    				<td><a href="javascript:void(0);" onclick="fun(${Product.id})">删除</a></td>
				</tr>
			</c:forEach>
		</table>
	</center>
  </body>
</html>
